1. Field of the Invention
The present invention relates to a shading method and shading apparatus for computer graphics which is used for shading a three-dimensional object which is displayed on a two-dimensional display.
2. Description of the Prior Art
In computer graphics, when a three-dimensional object is displayed on a two-dimensional display, the surface of the three-dimensional object is shaded so as to improve the reality and visibility of the three-dimensional object. The method for shading the surface of a three-dimensional object is named shading. For example, a shading display method is used where the position of a point light source is determined such that the surface perpendicular to the point light source becomes bright, with the brightness of the surface being proportional to the perpendicularity to the point light source.
The three-dimensional object displayed on the two-dimensional display has a complicated curved surface. To naturally and optimally shade the three-dimensional object with the complicated curved surface according to the shape thereof, a method for approximating the curved surface with a plurality of polygons, inputting values of vertex coordinates of the polygons, and obtaining values inside the polygons with the values given to the vertex coordinates by means of linear interpolation is used. The linear interpolation is conducted by using DDA (digital differential analyzer) computation where the variation of each interval of the coordinate grids is successively added (for example, as disclosed in Japanese Patent Laid-Open Publication No. Sho 61-52737).
To display a three-dimensional object on a two-dimensional display, pixels are provided at the coordinate grid points. Values (depth values and brightness values) according to the pixels are input.
As was described above, in the method for approximating a curved surface with a plurality of polygons, values of vertex coordinates of each polygon are input, and values inside each polygon are obtained by means of the linear interpolation. The coordinates of each vertex may deviate from a coordinate grid point.
However, thus far, values cannot be input to any coordinates other than coordinate grid points. To prevent that, when the coordinates of vertexes of polygons are obtained by approximating a curved surface deviating from the coordinate grid points, the values of the coordinates of vertexes of the polygons are treated as the values on the coordinate grid points nearest to the coordinates.
In this case, values of the coordinates close to the coordinate grid points are input to pixels at the coordinate grid points rather than inputting correct values to pixels at the coordinate grid points. Thus, when the three-dimensional object is moved or deformed or the light source is moved, the image flickers with the accuracy of one pixel.
Thus far, in a method for approximating a curved surface with a plurality of polygons, values of vertex coordinates of the polygon are input, and values inside each polygon are obtained with the input values for each of the vertex coordinates by means of the linear interpolation. The curved surface is approximated by a particular polygon, such as a trapezoid or a triangle.
When a curved surface is approximated with any polygon, a memory with a large amount of capacity is required. In other words, to process any polygon, the memory should store values of vertexes of the polygon at the same time. Thus, to process a polygon where the number of vertexes is unlimited, infinite memory capacity is required.
However, when a curved surface is approximated with a particular polygon such as a trapezoid or a triangle, the drawing efficiency becomes bad. Thus, when a curved surface could be approximated with any polygon, the drawing efficiency would be improved and a complicated curved surface would be optimally shaded on a real time basis.